<template>
  <div class="mainbody" aria-label="Coach">
    <div v-if="showTop">
      <bpm-c-form>
        <bpm-c-block :preadonly="readonlysNotTrav[0]"
                     :ptitle="inputTitle[0]"
                     pinputtype="sltpaymentinternalorder"
                     :showValue="internalordername"
                     @sltvalueChanged="setSelectedGridInfoCellIndex($event,0)"
                     v-model="internalorder" />
        <bpm-c-block :preadonly="readonlysNotTrav[1]"
                     :ptitle="inputTitle[1]"
                     pinputtype="sltpaymentsubject"
                     :showValue="subjectname"
                     @sltvalueChanged="setSelectedGridInfoCellIndex($event,1)"
                     v-model="subject" />
      </bpm-c-form>
      <bpm-c-form>
        <bpm-c-block :preadonly="readonlysNotTrav[2]"
                     :ptitle="inputTitle[2]"
                     pinputtype="number"
                     :validateExp="validateExp[2]"
                     @valueChanged="setSelectedGridInfoCellIndex($event,2)"
                     v-model="selectedGridInfo[inputKey[2]]" />
        <bpm-c-block :preadonly="readonlysNotTrav[3]"
                     :ptitle="inputTitle[3]"
                     pinputtype="number"
                     :validateExp="validateExp[3]"
                     @valueChanged="setSelectedGridInfoCellIndex($event,3)"
                     v-model="selectedGridInfo[inputKey[3]]" />
      </bpm-c-form>
      <bpm-c-form>
        <bpm-c-block :preadonly="readonlysNotTrav[4]"
                     :ptitle="inputTitle[4]"
                     pinputtype="number"
                     @valueChanged="setSelectedGridInfoCellIndex('',4)"
                     v-model="selectedGridInfo[inputKey[4]]" />
        <bpm-c-block :preadonly="readonlysNotTrav[5]"
                     :ptitle="inputTitle[5]"
                     pinputtype="number"
                     @valueChanged="setSelectedGridInfoCellIndex('',5)"
                     v-model="selectedGridInfo[inputKey[5]]" />
      </bpm-c-form>
      <bpm-c-form>
        <bpm-c-block :preadonly="readonlysNotTrav[6]"
                     :ptitle="inputTitle[6]"
                     pinputtype="textarea"
                     @valueChanged="setSelectedGridInfoCellIndex('',6)"
                     v-model="selectedGridInfo[inputKey[6]]" />
      </bpm-c-form>
    </div>
    <el-dialog v-if="hasDialog"
                  :title="title"
                  :visible.sync="isChailv"
                  width="980px"
                  append-to-body>
      <bpm-c-subnavbar @navClicked="navClicked"
                       :showLeft="false"
                       :rightShowArray="['close']"/>
      <bpm-c-toptitle :title="getLanguage('title.reimDetails')"
                      :isCollapse="false" v-if="showTop">
        <bpm-c-form>
        <bpm-c-block :preadonly="readonlysNotTrav[0]"
                     :ptitle="inputTitle[0]"
                     pinputtype="sltpaymentinternalorder"
                     :showValue="internalordername"
                     @sltvalueChanged="setSelectedGridInfoCellIndex($event,0)"
                     v-model="internalorder" />
        <bpm-c-block :preadonly="readonlysNotTrav[1]"
                     :ptitle="inputTitle[1]"
                     pinputtype="sltpaymentsubject"
                     @sltvalueChanged="setSelectedGridInfoCellIndex($event,1)"
                     v-model="subject" />
        </bpm-c-form>
        <bpm-c-form>
        <bpm-c-block :preadonly="readonlysNotTrav[2]"
                     :ptitle="inputTitle[2]"
                     pinputtype="number"
                     :validateExp="validateExp[2]"
                     @valueChanged="setSelectedGridInfoCellIndex('',2)"
                     v-model="selectedGridInfo[inputKey[2]]" />
        <bpm-c-block :preadonly="readonlysNotTrav[3]"
                     :ptitle="inputTitle[3]"
                     pinputtype="number"
                     :validateExp="validateExp[3]"
                     @valueChanged="setSelectedGridInfoCellIndex('',3)"
                     v-model="selectedGridInfo[inputKey[3]]" />
        </bpm-c-form>
        <bpm-c-form>
        <bpm-c-block :preadonly="readonlysNotTrav[4]"
                     :ptitle="inputTitle[4]"
                     pinputtype="number"
                     @valueChanged="setSelectedGridInfoCellIndex('',4)"
                     v-model="selectedGridInfo[inputKey[4]]" />
        <bpm-c-block :preadonly="readonlysNotTrav[5]"
                     :ptitle="inputTitle[5]"
                     pinputtype="number"
                     @valueChanged="setSelectedGridInfoCellIndex('',5)"
                     v-model="selectedGridInfo[inputKey[5]]" />
        </bpm-c-form>
        <bpm-c-form>
        <bpm-c-block :preadonly="readonlysNotTrav[6]"
                     :ptitle="inputTitle[6]"
                     pinputtype="textarea"
                     @valueChanged="setSelectedGridInfoCellIndex('',6)"
                     v-model="selectedGridInfo[inputKey[6]]" />
        </bpm-c-form>
      </bpm-c-toptitle>
      <bpm-c-toptitle :title="getLanguage('title.ravelDetails')"
                      :isCollapse="false">
        <div>
          <bpm-c-tab :preadonly="false"
                     :hideTab="hideTab"
                     :ptabs="tab"
                     v-model="tabIndex"/>
          <div>
            <bpm-d-grid
              ref="paymentgridallgrid"
              :note="gridNote"
              :key="tabIndex"
              :head="head[tabIndex]"
              :showCheckbox="true"
              :height="200"
              :showArray="showArray[tabIndex]"
              :gridInfo="gridInfo[tabIndex]"
              :gridTitleInfo="gridTitleInfo[tabIndex]"
              :gridTypeInfo="gridTypeInfo[tabIndex]"
              :gridShowInfo="gridShowInfo[tabIndex]"
              :gridWidthInfo="gridWidthInfo[tabIndex]"
              :pageMax="pageMax[tabIndex]"
              :pageStart="pageStart[tabIndex]"
              :pageCount="pageCount[tabIndex]"
              :writeAble="writeAble"
              :validateExp="subvalidateExp[tabIndex]"
              @gridStatusChanged="gridStatusChanged"
              @gridPageChanged="gridPageChanged($event,tabIndex)"
              @saveClicked="saveClicked"
              @deleteClicked="deleteClicked"
              @gridClicked="gridClicked"
              @gridDBLClicked="gridDBLClicked"
              @gridCheckedChanged="gridCheckedChanged($event,tabIndex)"
            />
            <bpm-c-form>
            <bpm-c-block :preadonly="true"
                         :pline="1"
                         :ptitle="getLanguage('label.whBtStaydetails.actualremibursesum')"
                         pinputtype="number"
                         :pcontent="totalNum" />
            </bpm-c-form>
          </div>
        </div>
      </bpm-c-toptitle>
    </el-dialog>
    <!--<bpm-c-toptitle title="差旅费明细"-->
    <bpm-c-toptitle v-else
                    :title="getLanguage('title.ravelDetails')" v-show="isChailv"
                    :isCollapse="false">
      <div>
        <bpm-c-tab :preadonly="false"
                   :hideTab="hideTab"
                   :ptabs="tab"
                   v-model="tabIndex"/>
        <div>
          <bpm-d-grid
            ref="paymentgridallgrid"
            :key="tabIndex"
            :head="head[tabIndex]"
            :showCheckbox="true"
            :height="200"
            :showArray="showArray[tabIndex]"
            :gridInfo="gridInfo[tabIndex]"
            :gridTitleInfo="gridTitleInfo[tabIndex]"
            :gridTypeInfo="gridTypeInfo[tabIndex]"
            :gridShowInfo="gridShowInfo[tabIndex]"
            :gridEditInfo="gridEditInfo[tabIndex]"
            :gridWidthInfo="gridWidthInfo[tabIndex]"
            :pageMax="pageMax[tabIndex]"
            :pageStart="pageStart[tabIndex]"
            :pageCount="pageCount[tabIndex]"
            :writeAble="writeAble"
            :validateExp="subvalidateExp[tabIndex]"
            @gridStatusChanged="gridStatusChanged"
            @gridPageChanged="gridPageChanged($event,tabIndex)"
            @addClicked="addClicked"
            @saveClicked="saveClicked"
            @deleteClicked="deleteClicked"
            @gridClicked="gridClicked"
            @gridDBLClicked="gridDBLClicked"
            @gridCellEditEnd="gridCellEditEnd"
            @gridCheckedChanged="gridCheckedChanged($event,tabIndex)"
          />
          <bpm-c-block :preadonly="true"
                       :pline="1"
                       :ptitle="getLanguage('label.whBtStaydetails.actualremibursesum')"
                       pinputtype="number"
                       :pcontent="totalNum" />
        </div>
      </div>
    </bpm-c-toptitle>
  </div>
</template>

<script>
import { mapState, mapActions } from 'vuex'

export default {
  name: 'bpmDFeeChoose',
  props: {
    title: '',
    dialogVisible: {
      type: Number,
      default: -1
    },
    pselectType: {
      type: String,
      default: ''
    },
    showExtraStyle: {
      type: Boolean,
      default: false
    },
    validateExp: {
      type: Object,
      default () {
        return {}
      }
    },
    gridStatus: ''
  },
  data () {
    let inputKey = ['internalordername', 'subjectname', 'notincludetaxessum', 'taxrate', 'reimbursesum', 'actualreimbursesum', 'summary']
    let subvalidateExp = [{}, {}, {}, {}]
    subvalidateExp[0] = {
      0: {
        flag: true,
        maxlength: 20,
        require: true
      },
      1: {
        flag: true,
        maxlength: 14,
        require: true,
        positiveDecimal: true
      },
      2: {
        flag: true,
        maxlength: 14,
        positiveDecimal: true
      },
      5: {
        flag: true,
        maxlength: 256
      }
    }
    subvalidateExp[1] = {
      0: {
        flag: true,
        maxlength: 21,
        require: true
      },
      1: {
        flag: true,
        maxlength: 21,
        require: true
      },
      2: {
        flag: true,
        maxlength: 3,
        require: true,
        positiveInteger: true
      },
      3: {
        flag: true,
        maxlength: 3,
        require: true,
        positiveInteger: true
      },
      4: {
        flag: true,
        maxlength: 14,
        require: true,
        positiveDecimal: true
      },
      5: {
        flag: true,
        maxlength: 14,
        positiveDecimal: true
      },
      8: {
        flag: true,
        maxlength: 256
      }
    }
    subvalidateExp[3] = {
      0: {
        flag: true,
        maxlength: 20,
        require: true
      },
      1: {
        flag: true,
        maxlength: 5,
        require: true,
        positiveDecimal: true
      },
      2: {
        flag: true,
        maxlength: 3,
        require: true,
        positiveInteger: true
      },
      4: {
        flag: true,
        maxlength: 256
      }
    }
    return {
      stdSubjectCode1: '500307000101',
      childGridStatus: ['', '', '', ''],
      subvalidateExp: subvalidateExp,
      tabIndex: 0,
      inputKey: inputKey,
      checkedList: [],
      subGridIndex: -1,
      gridLoading: false,
      isChailv: false
    }
  },
  computed: {
    ...mapState(['fybxzb', 'ssc', 'chooseDialogEnum', 'pageType', 'pageTypeEnum', 'gridPageInfo', 'lang', 'openSelectAlert', 'otherI18n']),
    gridNote () {
      if (this.pageType === this.pageTypeEnum.draft) {
        if (this.gridStatus === 'update') {
          return this.otherI18n.updateWarn
        } else {
          return this.otherI18n.dbclkNote
        }
      }
      if (this.pageType === this.pageTypeEnum.approveFee) {
        return ''
      }
      return ''
    },
    totalNum () {
      if (this.tabIndex === 0) {
        return this.fybxzb.total_ccf
      } else if (this.tabIndex === 1) {
        return this.fybxzb.total_zsf
      } else if (this.tabIndex === 2) {
        return this.fybxzb.total_czf
      } else if (this.tabIndex === 3) {
        return this.fybxzb.total_clbt
      }
    },
    inputTitle () {
      return [
        this.getLanguage('label.innerOrder'),
        this.getLanguage('label.costShareSubject'),
        this.getLanguage('label.whBtReimburseDdSub.notincludetaxessum'),
        this.getLanguage('label.whBtReimburseDdSub.taxrate'),
        this.getLanguage('label.whBtReimburseDdSub.reimbursesum'),
        this.getLanguage('label.whBtReimburseDdSub.actualreimbursesum'),
        this.getLanguage('label.whBtReimburseDdSub.summary')
      ]
    },
    head () {
      return ['train', 'hotel', 'taxi', 'extra']
    },
    hideTab () {
      if (this.pageType === this.pageTypeEnum.view) {
        return []
      } else {
        return [2]
      }
    },
    tab () {
      return [
        this.getLanguage('title.tab.ccfmx'),
        this.getLanguage('title.tab.zsfmx'),
        this.getLanguage('title.tab.czfmx'),
        this.getLanguage('title.tab.ccbtmx')
      ]
    },
    writeAble () {
      if (this.pageType === this.pageTypeEnum.view || this.pageType === this.pageTypeEnum.approve) {
        return false
      }
      return true
    },
    gridShowInfo () {
      let gridShowInfo = []
      gridShowInfo[0] = ['city', 'notaxamount', 'tax', 'billssum', 'actualremibursesum', 'remark']
      gridShowInfo[1] = ['city', 'hotelsname', 'days', 'notaxamount', 'tax', 'billssum', 'actualremibursesum', 'personNum', 'remark'] // togetherWoman,togetherMan
      gridShowInfo[2] = ['billscount', 'billssum', 'actualremibursesum', 'remark']
      gridShowInfo[3] = ['city', 'subsidycriteria', 'subsidydays', 'actualremibursesum', 'remark']
      return gridShowInfo
    },
    gridEditInfo () {
      let gridEditInfo = []
      if (this.pageType === this.pageTypeEnum.approveFee) {
        gridEditInfo[0] = ['notaxamount', 'tax']
        gridEditInfo[1] = ['notaxamount', 'tax'] // togetherWoman,togetherMan
        gridEditInfo[2] = []
        gridEditInfo[3] = []
      }
      return gridEditInfo
    },
    showArray () {
      if (this.pageType === this.pageTypeEnum.approveFee) {
        return [
          [],
          [],
          ['add', 'delete'],
          ['add', 'delete']
        ]
      }
      return [
        ['add', 'delete'],
        ['add', 'delete'],
        ['add', 'delete'],
        ['add', 'delete']
      ]
    },
    gridTitleInfo () {
      let gridTitleInfo = []
      gridTitleInfo[0] = [
        this.getLanguage('label.whBtFaredetails.city'),
        this.getLanguage('label.whBtFaredetails.notaxamount'),
        this.getLanguage('label.whBtFaredetails.tax'),
        this.getLanguage('label.whBtFaredetails.billssum'),
        this.getLanguage('label.whBtFaredetails.actualremibursesum'),
        this.getLanguage('label.whBtFaredetails.remark')
      ]
      gridTitleInfo[1] = [
        this.getLanguage('label.whBtStaydetails.city'),
        this.getLanguage('label.whBtStaydetails.hotelsname'),
        this.getLanguage('label.whBtStaydetails.days'),
        this.getLanguage('label.whBtStaydetails.notaxamount'),
        this.getLanguage('label.whBtStaydetails.tax'),
        this.getLanguage('label.whBtStaydetails.billssum'),
        this.getLanguage('label.whBtStaydetails.actualremibursesum'),
        this.getLanguage('label.whBtStaydetails.personNum'),
        this.getLanguage('label.whBtStaydetails.remark')
      ]
      gridTitleInfo[2] = [
        this.getLanguage('label.whBtTransportationdetails.billscount'),
        this.getLanguage('label.whBtTransportationdetails.billssum'),
        this.getLanguage('label.whBtTransportationdetails.actualremibursesum'),
        this.getLanguage('label.whBtTransportationdetails.remark')
      ]
      gridTitleInfo[3] = [
        this.getLanguage('label.whBtTravelsubsidydetails.city'),
        this.getLanguage('label.whBtTravelsubsidydetails.subsidycriteria'),
        this.getLanguage('label.whBtTravelsubsidydetails.subsidydays'),
        this.getLanguage('label.whBtTravelsubsidydetails.actualremibursesum'),
        this.getLanguage('label.whBtTravelsubsidydetails.remark')
      ]
      return gridTitleInfo
    },
    gridWidthInfo () {
      let gridWidthInfo = []
      gridWidthInfo[0] = [120, 120, 120, 120, 120, 340]
      gridWidthInfo[1] = [100, 100, 100, 100, 100, 100, 100, 100, 140]
      gridWidthInfo[2] = [220, 220, 200, 300]
      gridWidthInfo[3] = [160, 160, 160, 160, 300]
      return gridWidthInfo
    },
    gridTypeInfo () {
      let gridTypeInfo = []
      gridTypeInfo[0] = ['text', 'number', 'number', 'number', 'number', 'text']
      gridTypeInfo[1] = ['text', 'text', 'text', 'number', 'number', 'number', 'number', 'text', 'text']
      gridTypeInfo[2] = ['text', 'number', 'number', 'text']
      gridTypeInfo[3] = ['text', 'number', 'text', 'number', 'text']
      return gridTypeInfo
    },
    pageMax () {
      // let tab = ['车船费明细', '住宿费明细', '出租费明细', '出差补贴明细']
      let array = []
      array[0] = this.gridPageInfo.ssc.reimburse.whBtFareDetails.max
      array[1] = this.gridPageInfo.ssc.reimburse.whBtStayDetails.max
      array[2] = this.gridPageInfo.ssc.reimburse.whBtTransportationDetails.max
      array[3] = this.gridPageInfo.ssc.reimburse.whBtTravelSubsidyDetails.max
      return array
    },
    pageStart () {
      // let tab = ['车船费明细', '住宿费明细', '出租费明细', '出差补贴明细']
      let array = []
      array[0] = this.gridPageInfo.ssc.reimburse.whBtFareDetails.start
      array[1] = this.gridPageInfo.ssc.reimburse.whBtStayDetails.start
      array[2] = this.gridPageInfo.ssc.reimburse.whBtTransportationDetails.start
      array[3] = this.gridPageInfo.ssc.reimburse.whBtTravelSubsidyDetails.start
      return array
    },
    pageCount () {
      // let tab = ['车船费明细', '住宿费明细', '出租费明细', '出差补贴明细']
      let array = []
      array[0] = this.gridPageInfo.ssc.reimburse.whBtFareDetails.count
      array[1] = this.gridPageInfo.ssc.reimburse.whBtStayDetails.count
      array[2] = this.gridPageInfo.ssc.reimburse.whBtTransportationDetails.count
      array[3] = this.gridPageInfo.ssc.reimburse.whBtTravelSubsidyDetails.count
      return array
    },
    selectedGridInfo () {
      if (this.showExtraStyle) {
        console.log('chailvrow payment grid item', this.$store.state.chailvRow.ssc.reimburse.whBtReimburseDdSub)
        return this.$store.state.chailvRow.ssc.reimburse.whBtReimburseDdSub
      } else {
        console.log('payment grid item', this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub)
        return this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub
      }
    },
    internalorder: {
      get () {
        console.log('获取内部订单')
        return this.selectedGridInfo.internalordercode
      },
      set (value) {
        console.log('aaaaaaaaaaa========', value)
        this.$store.commit('updateSelectRowSscReimburseWhBtReimburseDdSub', {
          name: 'internalordercode',
          value: value
        })
      }
    },
    internalordername () {
      return this.selectedGridInfo.internalordername
    },
    subjectname () {
      return this.selectedGridInfo.subjectname
    },
    subject: {
      get () {
        return this.selectedGridInfo.subjectcode
      },
      set (value) {
        this.$store.commit('updateSelectRowSscReimburseWhBtReimburseDdSub', {
          name: 'subjectcode',
          value: value
        })
      }
    },
    readonlysNotTrav () {
      switch (this.pageType) {
        case this.pageTypeEnum.draft: {
          let roArray = []
          if (this.selectedGridInfo.subjectcode === '500307000901' || this.selectedGridInfo.subjectcode === '500307000101') {
            roArray = [false, false, true, true, true, true, false]
          } else {
            roArray = [false, false, false, false, true, true, false]
          }
          if (this.gridStatus === 'update') {
            roArray[0] = roArray[1] = true
          }
          return roArray
        }
        case this.pageTypeEnum.approveFee:
          return [true, true, false, false, true, true, true]
        case this.pageTypeEnum.approve:
          return [true, true, true, true, true, true, true]
        case this.pageTypeEnum.view:
        default:
          return [true, true, true, true, true, true, true]
      }
    },
    isDialogVisible () {
      return this.dialogVisible >= 0
    },
    reimbursecompanycode () {
      return this.ssc.reimburse.whBtReimburse.reimbursecompanycode
    },
    reimbursecostcentercode () {
      return this.ssc.reimburse.whBtReimburse.reimbursecostcentercode
    },
    preInternalorder () {
      return {
        reimbursecompanycode: this.reimbursecompanycode,
        reimbursecostcentercode: this.reimbursecostcentercode
      }
    },
    preSubject () {
      return {
        reimbursecompanycode: this.reimbursecompanycode,
        reimbursecostcentercode: this.reimbursecostcentercode,
        inwardOrderCode: this.selectedGridInfo.internalordercode
      }
    },
    showTop () {
      if (this.showExtraStyle) { return false }
      return this.pageType === this.pageTypeEnum.draft ||
        (this.pageType === this.pageTypeEnum.approveFee && this.selectedGridInfo.subjectcode !== this.stdSubjectCode1)
    },
    whBtTravelSubsidyDetails: {
      get () {
        return this.ssc.reimburse.whBtTravelSubsidyDetails
      },
      set (value) {
        this.$store.commit('SetDataSscReimburseWhBtTravelSubsidyDetails', value)
      }
    },
    whBtTransportationDetails: {
      get () {
        return this.ssc.reimburse.whBtTransportationDetails
      },
      set (value) {
        this.$store.commit('SetDataSscReimburseWhBtTransportationDetails', value)
      }
    },
    whBtFareDetails: {
      get () {
        return this.ssc.reimburse.whBtFareDetails
      },
      set (value) {
        this.$store.commit('SetDataSscReimburseWhBtFareDetails', value)
      }
    },
    whBtStayDetails: {
      get () {
        return this.ssc.reimburse.whBtStayDetails
      },
      set (value) {
        this.$store.commit('SetDataSscReimburseWhBtStayDetails', value)
      }
    },
    gridInfo () {
      return [this.whBtFareDetails, this.whBtStayDetails, this.whBtTransportationDetails, this.whBtTravelSubsidyDetails]
    },
    hasDialog () {
      return this.pageType === this.pageTypeEnum.draft
    }
  },
  watch: {
    // isChailv (to) {
    //   if (to) {
    //     this.getAllGrandSubTable()
    //   }
    // },
    reimbursecompanycode (to) {
      // 清空内部订单和核算科目数组
      this.$store.commit('updateDataSscReimburse', { name: 'internalOrderList', value: [] })
      this.$store.commit('updateDataSscReimburse', { name: 'budgetSubjectList', value: [] })
    },
    reimbursecostcentercode (to) {
      if (this.pageType !== this.pageTypeEnum.draft) {
        return
      }
      if (!to || to.length <= 0) {
        // 清空内部订单和核算科目数组
        this.$store.commit('updateDataSscReimburse', { name: 'internalOrderList', value: [] })
        this.$store.commit('updateDataSscReimburse', { name: 'budgetSubjectList', value: [] })
        return
      }
      let param = {}
      param.me = this
      param.queryInternalOrderCode = ''
      param.queryInternalOrderName = ''
      param.companyCode = this.ssc.reimburse.whBtReimburse.reimbursecompanycode
      param.costcenterCode = this.ssc.reimburse.whBtReimburse.reimbursecostcentercode
      this.queryInternalOrder(param)
    }
  },
  methods: {
    ...mapActions(['getDataFromTableCostshare', 'getDataFromTableDdSub', 'AJAX_Reim_013_Count_SubChild', 'AJAX_Reim_011_Draft_SaveData', 'updateTableBxZb', 'updateDataSscCachePaymentInfo', 'getDataFromTableTravelSubsidyDetails',
      'getDataFromTableTransportationDetails', 'getDataFromTableFareDetails', 'getDataFromTableStayDetails', 'getbxmxMidFromDb', 'AJAX_Reim_031_SubApproveFee_SaveData',
      'queryBudgetSubject', 'queryInternalOrder', 'updateReimburseSumByMid', 'callTotalMoney', 'clearRegInfo']),
    ...mapActions(['resetGridSelectRowWhBtReimburseDdSub', 'resetGridSelectRowWhBtFareDetails', 'resetGridSelectRowWhBtStayDetails']),
    ...mapActions(['resetGridSelectRowWhBtTravelSubsidyDetails', 'resetGridSelectRowWhBtTransportationDetails']),
    ...mapActions(['initWhBtFaredetails', 'initWhBtStaydetails', 'initWhBtTravelsubsidydetails', 'getDataSscReimburseFromMoreTable']),
    setSelectedGridInfoCellIndex (v, index) {
      console.log('setSelectedGridInfoCellIndex......', v, index)
      if (this.pageType === this.pageTypeEnum.draft) {
        if (index === 0) { // 内部订单
          if (this.openSelectAlert) {
          //   if (this.pageType === this.pageTypeEnum.draft) {
          //     JsReimburseDraft.delChaiLvDetail($CV('CVPageTable1'))
          //     JsReimburseDraft.updateOverBudgLineNo(this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub, [])// todo 修改表格颜色没有做
          //     // 删本父表
          //     dora.httpBpmDelBz({mids: this.$store.state.bxmcCheckedMids.split(','), tableName: 'wh_bt_reimburse_dd_sub'})
          //     // 调用011
          //     this.AJAX_Reim_011_Draft_SaveData({
          //       action: 'del',
          //       fatherOrChild: 'father',
          //       me: this,
          //       data: this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub
          //     })
          //     // 刷新本父表
          //     $CV('CVPageTable1').refreshCurData()
          //     // $CV('CostShareTable').refreshCurData()
          //   }
          //   this.getDataFromTableCostshare({me: this})
          //   // 计算可冲抵金额
          //   this.calculateAfter()
          //   // console.log('deleted==========================', this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub)
          //   let ddsubItem = this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub
          //   if (ddsubItem.subjectcode === '500307000101' || ddsubItem.subjectcode === '500307000901') {
          //     // 清除子表数据
          //     this.resetGridSelectRowWhBtFareDetails({me: this})
          //     this.resetGridSelectRowWhBtStayDetails({me: this})
          //     this.resetGridSelectRowWhBtTravelSubsidyDetails({me: this})
          //     this.resetGridSelectRowWhBtTransportationDetails({me: this})
          //     this.initWhBtFaredetails({me: this})
          //     this.initWhBtStaydetails({me: this})
          //     this.initWhBtTravelsubsidydetails({me: this})
          //   }
          //   this.resetGridSelectRowWhBtReimburseDdSub({me: this})
          } else {
            let vObj = JSON.parse(v)
            console.log('inner line.......3', vObj)
            // JsReimburseDraft.chgInnerOrder(vObj)
            this.selectedGridInfo.internalordername = vObj.inwardOrderName
            this.selectedGridInfo.subjectcode = this.selectedGridInfo.subjectname = ''
            this.isChailv = this.showExtraStyle
            if (this.isChailv) {
              let paramJson = {}
              paramJson.me = this
              // paramJson.tableNames = 'wh_bt_reimburse,wh_bt_reimburse_dd_sub,wh_bt_reimburse_costshare,wh_bt_travelsubsidydetails,wh_bt_transportationdetails,wh_bt_faredetails,wh_bt_staydetails,wh_bt_reimburse_rcm_details,wh_bt_reimburse_rcm_sub'
              paramJson.tableNames = 'WH_BT_FAREDETAILS,WH_BT_STAYDETAILS，WH_BT_TRAVELSUBSIDYDETAILS,WH_BT_REIMBURSE_DD_SUB'
              paramJson.BB = 'N'
              this.getDataSscReimburseFromMoreTable(paramJson)
            }
            if (!vObj || vObj.length <= 0 || !vObj.inwardOrderCode) {
              this.$store.commit('updateDataSscReimburse', {name: 'budgetSubjectList', value: []})
            } else {
              setTimeout(() => {
                let param = {}
                param.me = this
                param.companyCode = this.reimbursecompanycode
                param.costingCenterCode = this.reimbursecostcentercode
                param.inwardOrderCode = this.selectedGridInfo.internalordercode
                param.budgetSubjectName = ''
                param.budgetSubjectCode = ''
                param.flag = 'pay'
                console.log('inner line.......4', vObj, param)
                this.queryBudgetSubject(param)
              }, 100)
            }
          }
        } else if (index === 1) { // 科目
          let vObj1 = JSON.parse(v)
          vObj1 && this.$store.commit('updateSelectRowSscReimburseWhBtReimburseDdSub', {
            name: 'subjectcode',
            value: vObj1.budgetSubjectCode
          })
          vObj1 && this.$store.commit('updateSelectRowSscReimburseWhBtReimburseDdSub', {
            name: 'subjectname',
            value: vObj1.budgetSubjectName
          })
          this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.notincludetaxessum = 0
          this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.taxrate = 0
          this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.reimbursesum = 0
          this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.actualreimbursesum = 0
          if (this.showExtraStyle) {
            this.isChailv = true
          } else if (this.pageType !== this.pageTypeEnum.draft) {
            this.isChailv = false
          } else {
            this.isChailv = (vObj1.budgetSubjectCode === '500307000901' || vObj1.budgetSubjectCode === '500307000101')
          }
          if (this.isChailv) {
            this.getAllGrandSubTable()
          }
        } else if (index === 2) {
          this.draftVerifys()
        } else if (index === 3) {
          this.draftVerifytax()
        }
      } else if (this.pageType === this.pageTypeEnum.approveFee) {
        if (index === 0) { // 内部订单
          console.log('aaaaaaaaaaa========', this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub)
        } else if (index === 1) {
          console.log('index===1')
        } else if (index === 2) {
          this.approveFeeVerifys()
        } else if (index === 3) {
          this.approveFeeVerifytax()
        }
      }
    },
    getUuid () {
      var s = []
      var hexDigits = '0123456789abcdef'
      for (var i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1)
      }
      s[14] = '4' // bits 12-15 of the time_hi_and_version field to 0010
      s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1) // bits 6-7 of the clock_seq_hi_and_reserved to 01
      s[8] = s[13] = s[18] = s[23] = '-'

      var uuid = s.join('')
      return uuid
    },
    getAllGrandSubTable () {
      // 补贴 出租 交通 住宿
      setTimeout(() => {
        if (!this.whBtFareDetails || this.whBtFareDetails.length <= 0) {
          this.getDataFromTableFareDetails({me: this, async: true})
        }
        if (!this.whBtStayDetails || this.whBtStayDetails.length <= 0) {
          this.getDataFromTableStayDetails({me: this, async: true})
        }
        if (!this.whBtTransportationDetails || this.whBtTransportationDetails.length <= 0) {
          this.getDataFromTableTransportationDetails({me: this, async: true})
        }
        if (!this.whBtTravelSubsidyDetails || this.whBtTravelSubsidyDetails.length <= 0) {
          this.getDataFromTableTravelSubsidyDetails({me: this, async: true})
        }
      }, 100)
    },
    addClicked () {
      console.log('bbbbbbbbb', 'aaaaa')
      if (this.pageType === this.pageTypeEnum.approveFee) {
        this.getbxmxMidFromDb({
          me: this
        })
      }
    },
    saveClicked () {
      let me = this
      // 新逻辑
      // 新增1.如没有父表mid，则生产父表mid。2.生成孙子表mmid，传入tsid保存本孙子表。3.statAllDetails父表和关联表如分摊表的数据更新。4.011接口爷爷表即主表的更新。5.刷新页面
      // 修改1.使用父表mid。2.使用孙子表mmid，传入tsid保存本孙子表。3.statAllDetails父表和关联表如分摊表的数据更新。4.011接口爷爷表即主表的更新。5.刷新页面
      // 车船费明细', '住宿费明细', '出租费明细', '出差补贴明细
      let saveFlag = 'update'
      switch (this.tabIndex) {
        case 0:
          console.log('0车船费明细')
          if (this.pageType === this.pageTypeEnum.draft) {
            // 没填写摘要，不允许保存
            let summary = this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.summary
            if (summary === null || summary === '') {
              this.alert(this.getResource('alert.information.mytxzyxx'))
              return
            }
            let tax = this.$store.state.gridSelectRow.ssc.reimburse.whBtFareDetails.tax
            if (tax === null || tax === '' || tax === 0) {
              this.$store.state.gridSelectRow.ssc.reimburse.whBtFareDetails.tax = '0'
            }
            let czfObj = this.$store.state.gridSelectRow.ssc.reimburse.whBtFareDetails
            if (this.childGridStatus[0] === 'add') {
              saveFlag = ''
              czfObj.mid = this.$store.state.bxmxMid
              czfObj.mmid = 'MMID-' + this.getUuid()
              czfObj.tsId = this.$store.state.tsId
            }
            this.updateTableBxZb({
              saveFlag: saveFlag,
              me: this,
              tableName: 'wh_bt_faredetails',
              data: czfObj
            })
            this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.tsId = this.$store.state.gridSelectRow.ssc.reimburse.whBtFareDetails.tsId
            this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.mid = this.$store.state.gridSelectRow.ssc.reimburse.whBtFareDetails.mid
            this.AJAX_Reim_011_Draft_SaveData({
              me: this,
              data: this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub
            })
            // this.AJAX_Reim_013_Count_SubChild({me: this, async: true}) // 调用013算孙子表的各自合计金额 todo
            // this.getDataFromTableFareDetails({me: this, async: true})
            // this.getDataFromTableDdSub({me: this, async: true})
            // this.getDataFromTableCostshare({me: this, async: true})
            let paramJson = {}
            paramJson.me = this
            // paramJson.tableNames = 'wh_bt_reimburse,wh_bt_reimburse_dd_sub,wh_bt_reimburse_costshare,wh_bt_travelsubsidydetails,wh_bt_transportationdetails,wh_bt_faredetails,wh_bt_staydetails,wh_bt_reimburse_rcm_details,wh_bt_reimburse_rcm_sub'
            paramJson.tableNames = 'WH_BT_FAREDETAILS,WH_BT_REIMBURSE_COSTSHARE,WH_BT_REIMBURSE_DD_SUB'
            paramJson.BB = 'N'
            this.getDataSscReimburseFromMoreTable(paramJson)
            // 计算可冲抵金额
            this.calculateAfter()
          } else {
            // 再校验一次,因为原来是行编辑
            // 不含税金额,
            // 保存前校验。
            if (this.isMakeCert() === '-1') {
              this.alert(this.getResource('alert.information.yjzzbyxxg')) // 已经制证不允许修改
              return false
            }
            if (this.approveFeeTrainGridCheckNotaxamount() === false) {
              return false
            }
            if (this.approveFeeTrainGridCheckTax() === false) {
              return false
            }
            // 保存数据
            let obj = this.$store.state.gridSelectRow.ssc.reimburse.whBtFareDetails
            this.updateTableBxZb({
              saveFlag: saveFlag,
              me: this,
              tableName: 'WH_BT_FAREDETAILS',
              data: obj
            })
            // 重新计算表之间的关系
            this.$store.state.returnCode = '000000'
            this.AJAX_Reim_031_SubApproveFee_SaveData({
              me: this,
              tsId: obj.tsId,
              mid: obj.mid
            })
            // 检查失败，则不再执行；
            if (this.$store.state.returnCode !== '000000') {
              this.alert(this.getResource(this.$store.state.retMsg))
              this.$store.state.retMsg = ''
              return false
            }
            // this.getDataFromTableDdSub({me: this, async: true})
            // this.getDataFromTableCostshare({me: this, async: true})
            // this.getDataFromTableFareDetails({me: this, async: true})
            // this.AJAX_Reim_013_Count_SubChild({me: this, async: true}) // 调用013算孙子表的各自合计金额 todo
            let paramJson = {}
            paramJson.me = this
            // paramJson.tableNames = 'wh_bt_reimburse,wh_bt_reimburse_dd_sub,wh_bt_reimburse_costshare,wh_bt_travelsubsidydetails,wh_bt_transportationdetails,wh_bt_faredetails,wh_bt_staydetails,wh_bt_reimburse_rcm_details,wh_bt_reimburse_rcm_sub'
            paramJson.tableNames = 'WH_BT_FAREDETAILS,WH_VBT_REIMBURSE_RCM_DETAILS,WH_BT_REIMBURSE_COSTSHARE,WH_BT_REIMBURSE_DD_SUB,WH_BT_REIMBURSE'
            paramJson.BB = 'N'
            this.getDataSscReimburseFromMoreTable(paramJson)
            this.reloadRechargeMoney()
            return true
            /*****************************************/
          }
          break
        case 1:
          console.log('1-住宿费明细')
          if (this.pageType === this.pageTypeEnum.draft) {
            // 没填写摘要，不允许保存
            let summary = this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.summary
            if (summary === null || summary === '') {
              this.alert(this.getResource('alert.information.mytxzyxx'))
              return
            }
            let tax = this.$store.state.gridSelectRow.ssc.reimburse.whBtStayDetails.tax
            if (tax === null || tax === '' || tax === 0) {
              this.$store.state.gridSelectRow.ssc.reimburse.whBtStayDetails.tax = '0'
            }
            let czfObj = this.$store.state.gridSelectRow.ssc.reimburse.whBtStayDetails
            // JsReimburseDraft.beforeSaveData('', czfObj)

            if (this.childGridStatus[1] === 'add') {
              saveFlag = ''
              czfObj.mid = this.$store.state.bxmxMid
              czfObj.mmid = 'MMID-' + this.getUuid()
              czfObj.tsId = this.$store.state.tsId
            }
            this.updateTableBxZb({
              saveFlag: saveFlag,
              me: this,
              tableName: 'wh_bt_staydetails',
              data: czfObj
            })
            this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.tsId = this.$store.state.gridSelectRow.ssc.reimburse.whBtStayDetails.tsId
            this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.mid = this.$store.state.gridSelectRow.ssc.reimburse.whBtStayDetails.mid
            this.AJAX_Reim_011_Draft_SaveData({
              me: this,
              data: this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub
            })
            // this.AJAX_Reim_013_Count_SubChild({me: this, async: true}) // 调用013算孙子表的各自合计金额 todo
            // this.getDataFromTableStayDetails({me: this, async: true})
            // this.getDataFromTableDdSub({me: this, async: true})
            // this.getDataFromTableCostshare({me: this, async: true})
            let paramJson = {}
            paramJson.me = this
            // paramJson.tableNames = 'wh_bt_reimburse,wh_bt_reimburse_dd_sub,wh_bt_reimburse_costshare,wh_bt_travelsubsidydetails,wh_bt_transportationdetails,wh_bt_faredetails,wh_bt_staydetails,wh_bt_reimburse_rcm_details,wh_bt_reimburse_rcm_sub'
            paramJson.tableNames = 'WH_BT_STAYDETAILS,WH_BT_REIMBURSE_COSTSHARE,WH_BT_REIMBURSE_DD_SUB'
            paramJson.BB = 'N'
            this.getDataSscReimburseFromMoreTable(paramJson)
            // 计算可冲抵金额
            this.calculateAfter()
          } else {
            if (this.isMakeCert() === '-1') {
              this.alert(this.getResource('alert.information.yjzzbyxxg')) // 已经制证不允许修改
              return false
            }
            if (this.approveFeeHotelGridCheckNotaxamount() === false) {
              return false
            }
            if (this.approveFeeHotelGridCheckTax() === false) {
              return false
            }
            // 保存数据
            let obj = this.$store.state.gridSelectRow.ssc.reimburse.whBtStayDetails
            this.updateTableBxZb({
              saveFlag: saveFlag,
              me: this,
              tableName: 'WH_BT_STAYDETAILS',
              data: obj
            })
            // 重新计算表之间的关系
            this.$store.state.returnCode = '000000'
            this.AJAX_Reim_031_SubApproveFee_SaveData({
              me: this,
              tsId: obj.tsId,
              mid: obj.mid
            })
            // 检查失败，则不再执行；
            if (this.$store.state.returnCode !== '000000') {
              this.alert(this.getResource(this.$store.state.retMsg))
              this.$store.state.retMsg = ''
              return false
            }
            // this.getDataFromTableDdSub({me: this, async: true})
            // this.getDataFromTableCostshare({me: this, async: true})
            // this.getDataFromTableStayDetails({me: this, async: true})
            // this.AJAX_Reim_013_Count_SubChild({me: this, async: true}) // 调用013算孙子表的各自合计金额 todo
            let paramJson = {}
            paramJson.me = this
            // paramJson.tableNames = 'wh_bt_reimburse,wh_bt_reimburse_dd_sub,wh_bt_reimburse_costshare,wh_bt_travelsubsidydetails,wh_bt_transportationdetails,wh_bt_faredetails,wh_bt_staydetails,wh_bt_reimburse_rcm_details,wh_bt_reimburse_rcm_sub'
            paramJson.tableNames = 'WH_BT_REIMBURSE_COSTSHARE,WH_BT_STAYDETAILS,WH_VBT_REIMBURSE_RCM_DETAILS,WH_BT_REIMBURSE_DD_SUB,WH_BT_REIMBURSE'
            paramJson.BB = 'N'
            this.getDataSscReimburseFromMoreTable(paramJson)
            this.reloadRechargeMoney()
            return true
            /*****************************************/
          }
          break
        case 2:// 起草没有出租费了
          console.log('2出租费明细')
          // 再校验一次,因为原来是行编辑
          break
        case 3:
          console.log('3出差补贴明细')
          if (this.pageType === this.pageTypeEnum.draft) {
            // 没填写摘要，不允许保存
            let summary = this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.summary
            if (summary === null || summary === '') {
              this.alert(this.getResource('alert.information.mytxzyxx'))
              return
            }
            let clbtObj = this.$store.state.gridSelectRow.ssc.reimburse.whBtTravelSubsidyDetails
            if (this.childGridStatus[3] === 'add') {
              saveFlag = ''
              clbtObj.mid = this.$store.state.bxmxMid
              clbtObj.mmid = 'MMID-' + this.getUuid()
              clbtObj.tsId = this.$store.state.tsId
            }
            this.updateTableBxZb({
              saveFlag: saveFlag,
              me: this,
              tableName: 'WH_BT_TRAVELSUBSIDYDETAILS',
              data: clbtObj
            })
            this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.tsId = this.$store.state.gridSelectRow.ssc.reimburse.whBtTravelSubsidyDetails.tsId
            this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub.mid = this.$store.state.gridSelectRow.ssc.reimburse.whBtTravelSubsidyDetails.mid
            this.AJAX_Reim_011_Draft_SaveData({
              me: this,
              data: this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub
            })
            // this.AJAX_Reim_013_Count_SubChild({me: this, async: true}) // 调用013算孙子表的各自合计金额 todo
            // this.getDataFromTableTravelSubsidyDetails({me: this, async: true})
            // this.getDataFromTableDdSub({me: this, async: true})
            // this.getDataFromTableCostshare({me: this, async: true})
            let paramJson = {}
            paramJson.me = this
            // paramJson.tableNames = 'wh_bt_reimburse,wh_bt_reimburse_dd_sub,wh_bt_reimburse_costshare,wh_bt_travelsubsidydetails,wh_bt_transportationdetails,wh_bt_faredetails,wh_bt_staydetails,wh_bt_reimburse_rcm_details,wh_bt_reimburse_rcm_sub'
            paramJson.tableNames = 'WH_BT_TRAVELSUBSIDYDETAILS,WH_BT_REIMBURSE_COSTSHARE,WH_BT_REIMBURSE_DD_SUB'
            paramJson.BB = 'N'
            this.getDataSscReimburseFromMoreTable(paramJson)
            // 计算可冲抵金额
            this.calculateAfter()
          } else {
            if (this.isMakeCert() === '-1') {
              this.alert(this.getResource('alert.information.yjzzbyxxg')) // 已经制证不允许修改
              return
            }
            // 保存数据
            let clbtObj = this.$store.state.gridSelectRow.ssc.reimburse.whBtTravelSubsidyDetails
            if (this.childGridStatus[3] === 'add') {
              saveFlag = ''
              clbtObj.mid = this.$store.state.bxmxMid
              clbtObj.mmid = 'MMID-' + this.getUuid()
              clbtObj.tsId = this.$store.state.tsId
            }
            this.updateTableBxZb({
              saveFlag: saveFlag,
              me: this,
              tableName: 'WH_BT_TRAVELSUBSIDYDETAILS',
              data: clbtObj
            })
            // 重新计算表之间的关系
            this.$store.state.returnCode = '000000'
            this.AJAX_Reim_031_SubApproveFee_SaveData({
              me: this,
              tsId: clbtObj.tsId,
              mid: clbtObj.mid
            })
            // 检查失败，则不再执行；
            if (this.$store.state.returnCode !== '000000') {
              this.alert(this.getResource(this.$store.state.retMsg))
              this.$store.state.retMsg = ''
              return
            }
            // this.getDataFromTableDdSub({me: this, async: true})
            // this.getDataFromTableCostshare({me: this, async: true})
            // this.getDataFromTableTravelSubsidyDetails({me: this, async: true})
            // this.AJAX_Reim_013_Count_SubChild({me: this, async: true}) // 调用013算孙子表的各自合计金额 todo
            let paramJson = {}
            paramJson.me = this
            // paramJson.tableNames = 'wh_bt_reimburse,wh_bt_reimburse_dd_sub,wh_bt_reimburse_costshare,wh_bt_travelsubsidydetails,wh_bt_transportationdetails,wh_bt_faredetails,wh_bt_staydetails,wh_bt_reimburse_rcm_details,wh_bt_reimburse_rcm_sub'
            paramJson.tableNames = 'WH_BT_REIMBURSE_COSTSHARE,WH_BT_TRAVELSUBSIDYDETAILS,WH_VBT_REIMBURSE_RCM_DETAILS,WH_BT_REIMBURSE_DD_SUB,WH_BT_REIMBURSE'
            paramJson.BB = 'N'
            this.getDataSscReimburseFromMoreTable(paramJson)
            this.reloadRechargeMoney()
            /*****************************************/
          }
          break
      }
      // mmsuna hide
      this.$refs.paymentgridallgrid.hideGridHead(true)
    },
    gridClicked (index, item) {
      console.log('bbbbbgridclicked===', index, item)
      this.subGridIndex = index
      this.$store.state.whBtReimburseDdSub.tsId = item.tsId
      this.$store.state.whBtReimburseDdSub.mid = item.mid
      this.$store.state.whBtReimburseDdSub.subjectcode = '500307000101' // 差旅费
    },
    gridDBLClicked (index, item) {
      switch (this.tabIndex) {
        case 0:
          this.$store.state.gridSelectRow.ssc.reimburse.whBtFareDetails = item
          break
        case 1:
          this.$store.state.gridSelectRow.ssc.reimburse.whBtStayDetails = item
          break
        case 2:
          this.$store.state.gridSelectRow.ssc.reimburse.whBtTransportationDetails = item
          break
        case 3:
          this.$store.state.gridSelectRow.ssc.reimburse.whBtTravelSubsidyDetails = item
          break
      }
    },
    updateClicked () {},
    deleteClicked () {
      console.log('deleteClicked this.tabIndex', this.tabIndex)
      switch (this.tabIndex) {
        case 0:
          if (this.pageType === this.pageTypeEnum.draft) {
            this.httpBpmDelBz({delKey: 'mmid', mids: this.$store.state.fareCheckedMmids.split(','), tableName: 'wh_bt_FareDetails'})
            this.AJAX_Reim_011_Draft_SaveData({
              action: 'del',
              fatherOrChild: 'child',
              me: this,
              data: this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub
            })
            // this.getDataFromTableFareDetails({me: this, async: true})
            // this.getDataFromTableDdSub({me: this, async: true})
            // this.getDataFromTableCostshare({me: this, async: true})
            let paramJson = {}
            paramJson.me = this
            // paramJson.tableNames = 'wh_bt_reimburse,wh_bt_reimburse_dd_sub,wh_bt_reimburse_costshare,wh_bt_travelsubsidydetails,wh_bt_transportationdetails,wh_bt_faredetails,wh_bt_staydetails,wh_bt_reimburse_rcm_details,wh_bt_reimburse_rcm_sub'
            paramJson.tableNames = 'WH_BT_FAREDETAILS,WH_BT_REIMBURSE_COSTSHARE,WH_BT_REIMBURSE_DD_SUB'
            paramJson.BB = 'N'
            this.getDataSscReimburseFromMoreTable(paramJson)
            // 计算可冲抵金额
            this.calculateAfter()
          }
          break
        case 1:
          if (this.pageType === this.pageTypeEnum.draft) {
            this.httpBpmDelBz({delKey: 'mmid', mids: this.$store.state.stayCheckedMmids.split(','), tableName: 'wh_bt_staydetails'})
            this.AJAX_Reim_011_Draft_SaveData({
              action: 'del',
              me: this,
              fatherOrChild: 'child',
              data: this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub
            })
            // this.getDataFromTableStayDetails({me: this, async: true})
            // this.getDataFromTableDdSub({me: this, async: true})
            // this.getDataFromTableCostshare({me: this, async: true})
            let paramJson = {}
            paramJson.me = this
            // paramJson.tableNames = 'wh_bt_reimburse,wh_bt_reimburse_dd_sub,wh_bt_reimburse_costshare,wh_bt_travelsubsidydetails,wh_bt_transportationdetails,wh_bt_faredetails,wh_bt_staydetails,wh_bt_reimburse_rcm_details,wh_bt_reimburse_rcm_sub'
            paramJson.tableNames = 'WH_BT_STAYDETAILS,WH_BT_REIMBURSE_COSTSHARE,WH_BT_REIMBURSE_DD_SUB'
            paramJson.BB = 'N'
            this.getDataSscReimburseFromMoreTable(paramJson)
            // 计算可冲抵金额
            this.calculateAfter()
          }
          break
        case 2:
        case 3:
          if (this.pageType === this.pageTypeEnum.draft) {
            this.httpBpmDelBz({delKey: 'mmid', mids: this.$store.state.travelSubsidyCheckedMmids.split(','), tableName: 'WH_BT_TRAVELSUBSIDYDETAILS'})
            this.AJAX_Reim_011_Draft_SaveData({
              action: 'del',
              me: this,
              fatherOrChild: 'child',
              data: this.$store.state.gridSelectRow.ssc.reimburse.whBtReimburseDdSub
            })
            // this.getDataFromTableTravelSubsidyDetails({me: this, async: true})
            // this.getDataFromTableDdSub({me: this, async: true})
            // this.getDataFromTableCostshare({me: this, async: true})
            let paramJson = {}
            paramJson.me = this
            // paramJson.tableNames = 'wh_bt_reimburse,wh_bt_reimburse_dd_sub,wh_bt_reimburse_costshare,wh_bt_travelsubsidydetails,wh_bt_transportationdetails,wh_bt_faredetails,wh_bt_staydetails,wh_bt_reimburse_rcm_details,wh_bt_reimburse_rcm_sub'
            paramJson.tableNames = 'WH_BT_TRAVELSUBSIDYDETAILS,WH_BT_REIMBURSE_COSTSHARE,WH_BT_REIMBURSE_DD_SUB'
            paramJson.BB = 'N'
            this.getDataSscReimburseFromMoreTable(paramJson)
            // 计算可冲抵金额
            this.calculateAfter()
          } else {
            if (this.isMakeCert() === '-1') {
              this.alert(this.getResource('alert.information.yjzzbyxxg')) // 已经制证不允许修改
              return false
            }
            this.httpBpmDelBz({
              delKey: 'mmid',
              mids: this.$store.state.travelSubsidyCheckedMmids.split(','),
              tableName: 'WH_BT_TRAVELSUBSIDYDETAILS',
              async: false
            })
            this.AJAX_Reim_031_SubApproveFee_SaveData({
              action: 'del',
              me: this,
              tsId: this.$store.state.tsId,
              mid: this.$store.state.bxmxMid
            })
            // 检查失败，则不再执行；
            if (this.$store.state.returnCode !== '000000') {
              this.alert(this.getResource(this.$store.state.retMsg))
              this.$store.state.retMsg = ''
              return false
            }
            // this.getDataFromTableTravelSubsidyDetails({me: this, async: true})
            // this.getDataFromTableDdSub({me: this, async: true})
            let paramJson = {}
            paramJson.me = this
            // paramJson.tableNames = 'wh_bt_reimburse,wh_bt_reimburse_dd_sub,wh_bt_reimburse_costshare,wh_bt_travelsubsidydetails,wh_bt_transportationdetails,wh_bt_faredetails,wh_bt_staydetails,wh_bt_reimburse_rcm_details,wh_bt_reimburse_rcm_sub'
            paramJson.tableNames = 'WH_BT_TRAVELSUBSIDYDETAILS,WH_BT_REIMBURSE_COSTSHARE,WH_VBT_REIMBURSE_RCM_DETAILS,WH_BT_REIMBURSE_DD_SUB'
            paramJson.BB = 'N'
            this.getDataSscReimburseFromMoreTable(paramJson)
            /** *****统计汇总金额,并计算页面数据*******/
            // this.callTotalMoney({ // 这次请求是否有必要，待验证 marked by gyren
            //   me: this,
            //   tsId: this.$store.state.tsId
            // })
            this.reloadRechargeMoney()
            /*****************************************/
          }
          break
      }
      // this.AJAX_Reim_013_Count_SubChild({me: this, async: true}) // 调用013算孙子表的各自合计金额 todo
    },
    gridCheckedChanged (v, tabIndex) {
      console.log('gridCheckedChanged v', v)
      console.log('gridCheckedChanged tabIndex', tabIndex)
      switch (tabIndex) {
        case 0:
          let strs = ''
          for (var i = 0; i < v.length; i++) {
            strs += this.$store.state.ssc.reimburse.whBtFareDetails[v[i]].mmid + ','
          }
          if (strs !== '') {
            strs = strs.substring(0, strs.length - 1)
          }
          this.$store.state.fareCheckedMmids = strs
          console.log('gridCheckedChanged fareCheckedMids', strs)
          break
        case 1:
          let strs1 = ''
          for (let j = 0; j < v.length; j++) {
            strs1 += this.$store.state.ssc.reimburse.whBtStayDetails[v[j]].mmid + ','
          }
          if (strs1 !== '') {
            strs1 = strs1.substring(0, strs1.length - 1)
          }
          this.$store.state.stayCheckedMmids = strs1
          console.log('gridCheckedChanged stayCheckedMmids', strs1)
          break
        case 2:
          break
        case 3:
          let strs3 = ''
          for (var i = 0; i < v.length; i++) {
            strs3 += this.$store.state.ssc.reimburse.whBtTravelSubsidyDetails[v[i]].mmid + ','
            this.$store.state.bxmxMid = this.$store.state.ssc.reimburse.whBtTravelSubsidyDetails[v[i]].mid   //把父表mid存起来，删除补贴时使用。
          }
          if (strs3 !== '') {
            strs3 = strs3.substring(0, strs3.length - 1)
          }
          this.$store.state.travelSubsidyCheckedMmids = strs3
          console.log('gridCheckedChanged travelSubsidyCheckedMmids', strs3)
          break
      }
    },
    selectClick (i) {
      console.log(i)
      this.dialogVisible = i
    },
    selDialogClicked (aObj) {
      this.dialogVisible = -1
      console.log('choose', aObj)
    },
    setDialogClose () {
      this.dialogVisible = -1
    },
    gridStatusChanged (v) {
      this.childGridStatus[this.tabIndex] = v
    },
    gridPageChanged (v, index) {
      console.log('paymentgrid', v)
      if (v.name === 'count' || v.name === 'start') {
        let path = ''
        switch (index) {
          case 0: path = 'whBtFareDetails'; break
          case 1: path = 'whBtStayDetails'; break
          case 2: path = 'whBtTransportationDetails'; break
          case 3: path = 'whBtTravelSubsidyDetails'; break
          default: break
        }
        let json = {
          path: path,
          name: v.name,
          value: v.value
        }
        this.$store.commit('upGridPageInfoWithPathAndValue', json)
        switch (index) {
          case 0: this.getDataFromTableFareDetails({me: this, async: true}); break
          case 1: this.getDataFromTableStayDetails({me: this, async: true}); break
          case 2: this.getDataFromTableTransportationDetails({me: this, async: true}); break
          case 3: this.getDataFromTableTravelSubsidyDetails({me: this, async: true}); break
          default: break
        }
      }
    },
    checkValidate () {
      console.log(this.validateExp)
      if (!this.validateExp) {
        return {
          result: true
        }
      }
      for (let i in this.validateExp) {
        console.log(i)
        if (!this.validateExp[i] || !this.validateExp[i].flag || !this.validateExp[i].require) {
          continue
        }
        console.log(i, '1')
        if (this.readonlysNotTrav[i]) {
          continue
        }
        console.log(i, '2')
        let info = this.selectedGridInfo[this.inputKey[i]]
        if (!info) {
          return {
            result: false,
            title: this.inputTitle[i]
          }
        }
        console.log(i, '3')
        if (this.pageType === this.pageTypeEnum.approveFee) continue
        if (info === '0' || isNaN(parseInt(info))) {
          return {
            result: false,
            title: this.inputTitle[i]
          }
        }
      }
      return {
        result: true
      }
    },
    navClicked (v) {
      // do nothing...
      console.log('button clicked:========', v)
      this.$emit('paymentgridSaveClicked', v)
    },
    // grid列表行内编辑触发逻辑； marked by gyren
    gridCellEditEnd: function (record, recordFieldValue) {
      console.log('paymentgrid cell changed...', record, recordFieldValue, this.tabIndex)
      if (this.tabIndex === 0) {
        this.gridLoading = true
        setTimeout(() => {
          this.$store.state.gridSelectRow.ssc.reimburse.whBtFareDetails = record
          if (!this.saveClicked()) {
            this.getDataFromTableFareDetails({me: this, async: true})
          } else {
            this.tips(this.getResource('alert.tips.sjxgcg'))
          }
          this.gridLoading = false
        }, 100)
      } else if (this.tabIndex === 1) {
        // TODO sth when is 住宿费
        this.gridLoading = true
        setTimeout(() => {
          this.$store.state.gridSelectRow.ssc.reimburse.whBtStayDetails = record
          if (!this.saveClicked()) {
            this.getDataFromTableStayDetails({me: this, async: true})
          } else {
            this.tips(this.getResource('alert.tips.sjxgcg'))
          }
          this.gridLoading = false
        }, 100)
      }
      // this.$emit('gridCellEditEnd', record, recordFieldValue)
    }
  },
  mounted () {
    if (this.showExtraStyle) {
      this.isChailv = true
    } else if (this.pageType !== this.pageTypeEnum.draft) {
      this.isChailv = false
    } else {
      this.isChailv = (this.selectedGridInfo.subjectcode === '500307000901' || this.selectedGridInfo.subjectcode === '500307000101')
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .mainbody {
    width: 980px;
    min-height: 150px;
  }
</style>
